package com.twu.biblioteca.ui.menus.items.books;

import com.twu.biblioteca.library.Library;
import com.twu.biblioteca.ui.menus.AbstractMenu;
import com.twu.biblioteca.ui.menus.books.ListBooksMenu;
import com.twu.biblioteca.ui.menus.books.NoAvailableBooksMenu;
import com.twu.biblioteca.ui.menus.items.AbstractMenuItem;

/**
 * @author Alvi Jonathan Sait
 */
public class ListBooksMenuItem extends AbstractMenuItem {
    public ListBooksMenuItem() {
        super("List Books");
    }

    @Override
    public AbstractMenu handleAction(Library library) {
        if (library.getBooks().isEmpty()) {
            return new NoAvailableBooksMenu(library);
        }
        return new ListBooksMenu(library);
    }
}
